package com.ecpss;

import java.util.ArrayList;
import java.util.List;

public class ObjectEscaping {
    public static void main(String[] args) {
        MyList list = new MyList();
        Thread t1 = new Thread(() -> {
            list.add(1);
        });
        Thread t2 = new Thread(() -> {
            list.add(2);
        });
        t1.start();
        t2.start();
    }
}

class MyList {

    public void add(int value) {
        List<Integer> list = new ArrayList<>();
        list.add(value);
        System.out.println("Added: " + value);
    }
}